package com.feilong.edgeAI.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.feilong.edgeAI.ui.HomeActivity;

/**
 * @ClassName: BootBroadcastReceiver
 * @Description: java类作用描述
 * @Author: potato
 * @CreateDate: 2022/1/11 9:15
 * @UpdateUser: potato
 * @UpdateDate: 2022/1/11 9:15
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class BootBroadcastReceiver extends BroadcastReceiver {
    public static final String ACTION = "android.intent.action.BOOT_COMPLETED";

    @Override
    public void onReceive(Context context, Intent it) {
        Log.e("FL_BOOT_COMPLETED>>>", it.getAction());
        if (it.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {

            Intent intent = new Intent(context, HomeActivity.class);  // 要启动的Activity
            //1.如果自启动APP，参数为需要自动启动的应用包名
//            Intent intent = context.getPackageManager().getLaunchIntentForPackage("hyco_voice.hyco.com.hycovoicedemo");
            //下面这句话必须加上才能开机自动运行app的界面
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra("go_home",true);
            Log.e("FL_BOOT_COMPLETED", "onReceive: ");
            //2.如果自启动Activity
            context.startActivity(intent);
//            Toast.makeText(context,"开机",Toast.LENGTH_LONG).show();
            //3.如果自启动服务
//            context.startService(intent);
        }
    }
}